/**
 * 
 */
package io.gitee.falllee.dao.config;


import javax.sql.DataSource;

import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import io.gitee.falllee.dao.cache.DataCache;
import io.gitee.falllee.dao.core.Dao;
import io.gitee.falllee.dao.persistence.DataMapper;

/**
 * @author batty
 *
 */
@Configuration
@MapperScan("io.gitee.falllee.dao.persistence")
@ConditionalOnClass({ DataSource.class, SqlSessionFactory.class })
public class DaoConfiguration {
    
    @Bean
    public Dao dao(DataMapper dataMapper) {
        DataCache dataCache = new DataCache();
        return new Dao(dataMapper, dataCache);
    }
}
